<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — — —</label><br/>
      <label size="large" label-width="280px">* * * 燃气管道泄漏扩散分析模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — — —</label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="200px">
      <el-form-item label="燃气土壤浓度" prop="c">
        <el-select v-model="formData.c" placeholder="请选择燃气土壤浓度" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in cOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="泄露时间单位为秒" prop="t">
        <el-input-number step="1" v-model="formData.t" placeholder="请选择泄露时间单位为秒" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>扩散范围:{{r}}（米）</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleRQGD13} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,

        formData: {
          c: undefined,
          t: undefined,
        },
        rules: {
          c: [{
            required: true,
            message: '请选择燃气土壤浓度',
            trigger: 'change'
          }],
          t: [{
            required: true,
            message: '请选择泄露时间单位为秒',
            trigger: 'blur'
          }],
        },
        cOptions: [{
          "label": "1%",
          "value": 1
        }, {
          "label": "5%",
          "value": 2
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handleRQGD13(this.formData).then(response => {
          console.log(response)
          this.r = response.r;
            this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
